library(sf) library(tmap) setwd("C:/Users/acer/Desktop/AMAR/MAKTABKHUNEH/codes/IRAN data for R/New folder") getwd() iran <- st_read("irn_admbnda_adm1_unhcr_20190514.shp") centroid<-st_centroid(iran$geometry) x_y<-st_coordinates(centroid) x<-x_y[seq(1:(length(x_y)/2))] y<-x_y[-seq(1:(length(x_y)/2))] value<-c(38.60495136,87.83357275,8.901777414,8.901777414,143.4679176,30.60280818,468.8546899,123.9922812,11.47617623,8.901777414,8.901777414,37.4972544,36.65557381,37.85991692,8.901777414,8.901777414,25.82722887,7.924819906,33.77607238,511.5312955,8.901777414,196.9228989,6.226051114,132.5365321,14.26806916,8.901777414,8.901777414,72.7792151,116.4338685,5.866918726,54.32400367)/1000 cost<-c(18.57508425,68.97644227,16.48469919,16.48469919,78.11293439,27.57374815,350.8675683,151.7380315,10.90213898,16.48469919,16.48469919,49.31294527,37.86700123,30.89330897,16.48469919,16.48469919,17.73786874,8.871365447,55.96202072,388.3994278,16.48469919,149.6838217,10.15992525,81.50538813,13.6642808,16.48469919,16.48469919,75.87376205,130.2769696,8.134816982,65.29172738)/1000 profit<-c(20.02986711,18.85713048,-7.582921779,-7.582921779,65.35498324,3.029060027,117.9871216,-27.74575026,0.574037245,-7.582921779,-7.582921779,-11.81569087,-1.211427424,6.966607942,-7.582921779,-7.582921779,8.08936013,-0.946545541,-22.18594834,123.1318678,-7.582921779,47.23907719,-3.933874137,51.03114394,0.603788364,-7.582921779,-7.582921779,-3.094546949,-13.84310115,-2.267898255,-10.96772371)/1000 value_capita<-c(1.42328E-05,6.91374E-05,7.65152E-06,9.39241E-06,3.66958E-05,6.3082E-06,0.000185267,6.63479E-05,6.6022E-06,5.01109E-06,1.53437E-05,7.32247E-06,1.15826E-05,1.93911E-05,1.88977E-06,1.24841E-05,1.61117E-05,4.50108E-06,2.36283E-05,0.000155785,1.03138E-05,0.0001546,4.81787E-06,2.05978E-05,2.03145E-05,3.20783E-06,1.15773E-05,5.48547E-06,3.56588E-05,5.15305E-06,5.13721E-05)*10^4 cost_capita<-c(6.84821E-06,5.42942E-05,1.41694E-05,1.73933E-05,1.99795E-05,5.68382E-06,0.000138645,8.11946E-05,6.27196E-06,9.27976E-06,2.84142E-05,9.62984E-06,1.19654E-05,1.5823E-05,3.49956E-06,2.31185E-05,1.10653E-05,5.03869E-06,3.91487E-05,0.000118285,1.90996E-05,0.000117513,7.862E-06,1.26669E-05,1.94548E-05,5.9404E-06,2.14394E-05,5.71871E-06,3.98984E-05,7.145E-06,6.17439E-05)*10^4 profit_capita<-c(7.38456E-06,1.48432E-05,-6.5179E-06,-8.00086E-06,1.67163E-05,6.24384E-07,4.66224E-05,-1.48467E-05,3.30242E-07,-4.26867E-06,-1.30704E-05,-2.30737E-06,-3.82792E-07,3.56817E-06,-1.60979E-06,-1.06345E-05,5.04635E-06,-5.37612E-07,-1.55203E-05,3.74993E-05,-8.78576E-06,3.70863E-05,-3.04413E-06,7.93086E-06,8.59657E-07,-2.73257E-06,-9.86206E-06,-2.3324E-07,-4.23956E-06,-1.99195E-06,-1.03718E-05)*10^4 productivity<-c(107.8319045,27.33850842,-45.99975826,-45.99975826,83.66730012,10.98530389,33.62725205,-18.28529736,5.265363483,-45.99975826,-45.99975826,-23.96062698,-3.199163876,22.55053982,-45.99975826,-45.99975826,45.60502871,-10.66967139,-39.64465196,31.70238135,-45.99975826,31.55924044,-38.7195185,62.61076122,4.418735039,-45.99975826,-45.99975826,-4.078546872,-10.62590049,-27.87890939,-16.79802963) employment<-c(153,570,42.48366013,42.48366013,635,145,2287,981,71.70588235,42.48366013,42.48366013,449.7058824,246,168,42.48366013,42.48366013,178.7058824,85.70588235,254.7058824,3534,42.48366013,897,91.70588235,482,64.70588235,42.48366013,42.48366013,419,746,37.70588235,478) employment_ratio<-c(0.017409748,0.112731322,0.011032281,0.014367052,0.043311598,0.008279516,0.237816951,0.158111558,0.011271072,0.006852546,0.023775196,0.024737631,0.022662409,0.026475831,0.002700273,0.018560732,0.030711124,0.015702771,0.05432358,0.290882153,0.012094028,0.202360192,0.022176302,0.01915823,0.025379135,0.005691206,0.015305456,0.008846109,0.062939034,0.008975048,0.121839936) three_factor<-c(47.3209206,44.90549487,5.79265305,5.382916468,50.08632214,21.65328942,77.7828812,24.34278723,20.60210053,6.515679247,3.751815234,14.41203905,19.70308597,27.84309479,7.461615724,4.45533072,34.12149033,17.19627282,7.348218261,78.61006466,4.698981047,68.11840754,10.52251822,38.01736526,22.33447211,7.205310274,4.493111934,17.99465465,20.68374248,11.90896813,22.86995046) iran2<-cbind(iran,centroid,x,y, value, cost, profit, productivity, employment, value_capita, cost_capita, profit_capita, employment_ratio, three_factor ) map1<-tm_shape(iran2) +tm_fill()+tm_dots(col = "value",size=6)+tm_borders()+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size = 2)+ tm_layout(legend.show =TRUE,title="Value (hemat)",title.position = c("center","top"),title.size=1.5) map1 map2<-tm_shape(iran2) + tm_fill() + tm_bubbles(size = "cost",col="red",scale=3)+tm_borders()+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size = 2)+ tm_layout(legend.show =TRUE,title="Cost (hemat)",title.position = c("center","top"),title.size=1.5) map2 map3<-tm_shape(iran2) +tm_fill()+ tm_dots(col = "profit", palette = "Reds",size=6)+tm_borders()+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size = 2)+ tm_layout(legend.show =TRUE,title="Profit (hemat)",title.position = c("center","top"),title.size=1.5) map3 map4<-tm_shape(iran2) + tm_fill()+tm_dots(col = "value_capita",size=6)+tm_borders()+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size = 2)+ tm_layout(legend.show =TRUE,title="Value/capita (million rial)",title.position = c("center","top"),title.size=1.5) map4 map5<-tm_shape(iran2) + tm_fill() + tm_bubbles(size = "cost_capita",col="red",scale=3)+tm_borders()+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size = 2)+ tm_layout(legend.show =TRUE,title="Cost/capita (million rial)",title.position = c("center","top"),title.size=1.5) map5 map6<-tm_shape(iran2) +tm_fill()+ tm_dots(col = "profit_capita", palette = "Reds",size=6)+tm_borders()+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size = 2)+ tm_layout(legend.show =TRUE,title="Profit/capita (million rial)",title.position = c("center","top"),title.size=1.5) map6 map7<-tm_shape(iran2) + tm_polygons(col = "productivity",palette="YlOrBr")+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size= 2)+ tm_layout(legend.show =TRUE,title="Productivity (%)",title.position = c("center","top"),title.size=1.5) map7 map8<-tm_shape(iran2) + tm_polygons(col = "employment_ratio")+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 100, 200), position = c("center", "bottom"),size= 2)+ tm_layout(legend.show =TRUE,title="Employment (%)",title.position = c("center","top"),title.size=1.5) map8 map9<-tm_shape(iran2) + tm_polygons(col = "three_factor",palette="Blues")+ tm_compass(type = "8star", position = c("right", "top"),size=3) + tm_scale_bar(breaks = c(0, 200, 400), position = c("center", "bottom"),size= 2)+ tm_layout(legend.show =TRUE,title="3 factor criterion (%)",title.position = c("center","top"),title.size=1.5) map9